import api from "./config.js"

export function deptInfo(data){
	return api('/policy/index/deptInfo',data)  
}
export function getDeptDetails(data){
	return api('/policy/index/getDeptDetails',data)  
}
export function policyList(data){
	return api('/policy/index/policyList',data)  
}
export function getPolicyDetails(data){
	return api('/policy/index/getPolicyDetails',data)  
}
export function setCollect(data){
	return api('/policy/index/setCollect',data)  
}
export function getCollect(data){
	return api('/policy/index/getCollect',data)  
}
export function getHistory(data){
	return api('/policy/index/getHistory',data)  
}
export function msgBoard(data){
	return api('/policy/index/msgBoard',data)  
}
export function getUserInfo() {
	uni.login({
		provider: 'weixin',
		success: res => {
			const WXBizDataCrypt=require('./WXBizDataCrypt.js')
			const appid = "wxd0bf7e3be4dc16ef"  //需替换
			const secret = "26b6cb913c3a14eb5d5ca7ff69523d97"  //需替换
			const url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid + '&secret=' + secret +
				'&js_code=' +
				res.code + '&grant_type=authorization_code';
			return api('/policy/index/getCode',{url})
			.then(res=>{
				uni.setStorageSync("openid",res.data.openId)
				uni.setStorageSync("session_key",res.data.session_key)
				//获取用户信息
				
			})
		},
		fail: err => {
			console.log('登录失败：', err)
		}
	})
}
